/* eslint-disable no-shadow */
/* eslint-disable no-confusing-arrow */
/* eslint-disable react/jsx-no-bind */
/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React, { useMemo } from 'react';
import withRouter from 'umi/withRouter';
import { Row, Col } from 'antd';
import ForeLineData from './CommonComp/ForeLineData';
import ScreenLogo from './CommonComp/Logo';
import config from './CommonComp/configs/yesterdayData';

/**
 * 中邮大屏，昨日数据
 *  */
const YesterdayDate = props => {
  const { isParentFull, match } = props;
  const { params: { platform = 'zyyz', id } = {} } = match || {}; // zyyz (中邮驿站) | zyyl (中邮驿路)

  const handelClick = (id, key) => {
    if (platform != key) {
      window.location.href = `/dashboard/${id}/${key}`;
    }
  };

  const title = useMemo(
    () => (
      <Row type="flex" align="middle">
        <Col style={{ opacity: platform == 'zyyz' ? 1 : 0.5, cursor: 'pointer' }}>
          <ScreenLogo size="small" platform="zyyz" onClick={handelClick.bind(null, id)} />
        </Col>
        <Col style={{ margin: '0 10px' }}>/</Col>
        <Col style={{ opacity: platform == 'zyyl' ? 1 : 0.5, cursor: 'pointer' }}>
          <ScreenLogo size="small" platform="zyyl" onClick={handelClick.bind(null, id)} />
        </Col>
      </Row>
    ),
    [platform, id],
  );

  return (
    <ForeLineData
      isParentFull={isParentFull}
      title={title}
      dispatchType={config[platform].dispatchType}
      config={config[platform].config}
    />
  );
};

export default withRouter(YesterdayDate);
